package cn.e4j.modular.api.service;


import cn.e4j.core.dto.impl.Dto;
import cn.e4j.core.util.InvokeUtil;
import cn.e4j.core.util.ToolUtil;
import cn.e4j.modular.api.mapper.BfcglMapper;
import cn.e4j.modular.api.mapper.WdhydMapper;
import cn.e4j.modular.crm.entity.GwakT;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Comparator;
import java.util.List;

@Service
public class WdhydService {


    @Autowired
    WdhydMapper wdhydMapper;


    public List<Dto> getList(Dto indto){
        List<Dto> count1 = wdhydMapper.getCount1(indto);
        for (Dto d:count1){
            QueryWrapper<GwakT> wrapper = new QueryWrapper<>();
            wrapper.eq("GWAK010",d.getString("GWAK010"));
            indto.put("CUSTOMERS",new GwakT().selectList(wrapper));
            Dto count2 = InvokeUtil.invokeBeanMethod2("cn.e4j.modular.api.mapper.WdhydMapper.getCount2",indto);
            if (ToolUtil.isNotEmpty(count2)){
                d.put("ACTIVECOUNT",count2.getBigDecimal("ACTIVECOUNT"));
                d.put("REALVAL",count2.getBigDecimal("REALVAL"));
            }
        }
        return count1;
    }

    public List<Dto> getInfo(Dto indto){
        return InvokeUtil.invokeBeanMethod2("cn.e4j.modular.api.mapper.WdhydMapper.getInfo",indto);
    }
}
